package main

import (
	"errors"
	"github.com/irealing/argsparser"
	"log"
)

var (
	config = &PassConfig{}
)

type PassConfig struct {
	Host    string `param:"host",usage:"绑定IP地址"`
	Port    uint16 `param:"port",usage:"绑定端口号"`
	Backend string `param:"backend",usage:"后端MySQL地址"`
}

func (pc *PassConfig) Validate() error {
	if pc.Host == "" || pc.Backend == "" || pc.Port == 0 {
		return errors.New("配置异常")
	}
	return nil
}
func init() {
	ap := argsparser.New(config)
	ap.Init()
	if err := ap.Parse(); err != nil {
		log.Fatal(err)
	}
}
